<?php
/**
 * Nad�b (Mak�-Nad�b)
 *
 * @filesource 
 * @copyright  Copyright 2010 mateusweb.com.br
 * @license    Freeware
 * @package    Nadeb_Data_Grid
 * @subpackage Nadeb.Grid.Sql
 * @version    2.0
 */

abstract class Nadeb_Report_Header
{
	public static function get_xhtml($_headerConfigs)
	{
		$params   = $_headerConfigs["params"];
		$columns  = $_headerConfigs["columns"];
		$readOnly = $_headerConfigs["read_only"];
		$tools    = $_headerConfigs["tools"];
		$filters  = $_headerConfigs["filters"];
		$totReg   = $_headerConfigs["totReg"];
		
		$url_path = "/{$params['module']}/{$params['controller']}/form/";
		if( isset($params['rel']) ) $url_path .= "rel/" . $params['rel'];
		
		$gd = "\t\t\t<thead>\n";
		if( !$readOnly )
		{
		    $gd .= "\t\t\t\t<tr class=\"buttons\">\n";
			$gd .= "\t\t\t\t\t<th colspan=\"99\">\n";
			$gd .= "\t\t\t\t\t\t\t<a href='$url_path' class=\"buttom\">Inserir</a>\n";
			$gd .= "\t\t\t\t\t\t\t<input type=\"submit\" class=\"bot_excluir\" value=\"Excluir\" />\n";
			if($filters) $gd .= "\t\t\t\t\t\t\t<a href='#' class=\"buttom show_filters\">Filtros</a>\n";
			$gd .= "\t\t\t\t\t<strong class=\"abRex\">Total de cadastros: {$totReg}</strong>\n";
			$gd .= "\t\t\t\t\t</th>\n";
			$gd .= "\t\t\t\t</tr>\n";
		}
		else
		{
			if($filters)
			{
			    $gd .= "\t\t\t\t<tr class=\"buttons\">\n";
				$gd .= "\t\t\t\t\t<th colspan=\"99\">\n";
				$gd .= "\t\t\t\t\t\t\t<a href='#' class=\"buttom show_filters\">Filtros</a>\n";
				$gd .= "\t\t\t\t\t<strong class=\"abRex\">Total de cadastros: {$totReg}</strong>\n";
				$gd .= "\t\t\t\t\t</th>\n";
				$gd .= "\t\t\t\t</tr>\n";
			}
		}

		$gd .= "\t\t\t\t<tr>\n";
	    $x = 0;
	    if( !$readOnly )
			$gd .= "\t\t\t\t\t<th class='td_checkbox'><a href=\"//todos\">all</a></th>\n";

		if( $columns )
			foreach($columns as $columns => $val)
				if( $columns  != "id") $gd .= "\t\t\t\t\t<th class='top_".$x++."'>{$val["header"]}</th>\n";

		if( $tools )
			$gd .= "\t\t\t\t\t<th colspan=\"". count($tools) ."\" class=\"th_editar\">Editar</th>\n";
		$gd .= "\t\t\t\t</tr>\n\t\t\t</thead>\n";
		
		return $gd;
	}
}
